<?php require_once('Connections/sepolwan_connect.php'); ?>
<?php
if (!isset($_SESSION)) {
  session_start();
}
$MM_authorizedUsers = "";
$MM_donotCheckaccess = "true";

// *** Restrict Access To Page: Grant or deny access to this page
function isAuthorized($strUsers, $strGroups, $UserName, $UserGroup) { 
  // For security, start by assuming the visitor is NOT authorized. 
  $isValid = False; 

  // When a visitor has logged into this site, the Session variable MM_Username set equal to their username. 
  // Therefore, we know that a user is NOT logged in if that Session variable is blank. 
  if (!empty($UserName)) { 
    // Besides being logged in, you may restrict access to only certain users based on an ID established when they login. 
    // Parse the strings into arrays. 
    $arrUsers = Explode(",", $strUsers); 
    $arrGroups = Explode(",", $strGroups); 
    if (in_array($UserName, $arrUsers)) { 
      $isValid = true; 
    } 
    // Or, you may restrict access to only certain users based on their username. 
    if (in_array($UserGroup, $arrGroups)) { 
      $isValid = true; 
    } 
    if (($strUsers == "") && true) { 
      $isValid = true; 
    } 
  } 
  return $isValid; 
}

$MM_restrictGoTo = "index.php";
if (!((isset($_SESSION['MM_Username'])) && (isAuthorized("",$MM_authorizedUsers, $_SESSION['MM_Username'], $_SESSION['MM_UserGroup'])))) {   
  $MM_qsChar = "?";
  $MM_referrer = $_SERVER['PHP_SELF'];
  if (strpos($MM_restrictGoTo, "?")) $MM_qsChar = "&";
  if (isset($_SERVER['QUERY_STRING']) && strlen($_SERVER['QUERY_STRING']) > 0) 
  $MM_referrer .= "?" . $_SERVER['QUERY_STRING'];
  $MM_restrictGoTo = $MM_restrictGoTo. $MM_qsChar . "accesscheck=" . urlencode($MM_referrer);
  header("Location: ". $MM_restrictGoTo); 
  exit;
}
?>
<?php
if (!function_exists("GetSQLValueString")) {
function GetSQLValueString($theValue, $theType, $theDefinedValue = "", $theNotDefinedValue = "") 
{
  if (PHP_VERSION < 6) {
    $theValue = get_magic_quotes_gpc() ? stripslashes($theValue) : $theValue;
  }

  $theValue = function_exists("mysql_real_escape_string") ? mysql_real_escape_string($theValue) : mysql_escape_string($theValue);

  switch ($theType) {
    case "text":
      $theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL";
      break;    
    case "long":
    case "int":
      $theValue = ($theValue != "") ? intval($theValue) : "NULL";
      break;
    case "double":
      $theValue = ($theValue != "") ? doubleval($theValue) : "NULL";
      break;
    case "date":
      $theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL";
      break;
    case "defined":
      $theValue = ($theValue != "") ? $theDefinedValue : $theNotDefinedValue;
      break;
  }
  return $theValue;
}
}

$colname_sesi = "-1";
if (isset($_SESSION['MM_Username'])) {
  $colname_sesi = $_SESSION['MM_Username'];
}
mysql_select_db($database_sepolwan_connect, $sepolwan_connect);
$query_sesi = sprintf("SELECT * FROM memberdb WHERE email = %s", GetSQLValueString($colname_sesi, "text"));
$sesi = mysql_query($query_sesi, $sepolwan_connect) or die(mysql_error());
$row_sesi = mysql_fetch_assoc($sesi);
$totalRows_sesi = mysql_num_rows($sesi);

$colname_notice = "-1";
if (isset($row_sesi['id'])) {
  $colname_notice = $row_sesi['id'];
}
mysql_select_db($database_sepolwan_connect, $sepolwan_connect);
$query_notice = sprintf("SELECT * FROM komentar_mmber WHERE id_notice = %s AND id_member <>  '".$row_sesi['id']."' ORDER by id DESC Limit 10", GetSQLValueString($colname_notice, "int"));
$notice = mysql_query($query_notice, $sepolwan_connect) or die(mysql_error());
$row_notice = mysql_fetch_assoc($notice);
$totalRows_notice = mysql_num_rows($notice);

$updateSQL = sprintf("UPDATE memberdb SET notice=%s WHERE id=%s",
                       
					   GetSQLValueString(0, "text"),
                       GetSQLValueString($row_sesi['id'], "text"));
					   
	mysql_select_db($database_sepolwan_connect, $sepolwan_connect);
  $Result1 = mysql_query($updateSQL, $sepolwan_connect) or die(mysql_error());
?>
<?php include "tambah/date.php" ?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Pemberitahuan</title>
<link href="<?php echo $base ?>gaya/style.css" rel="stylesheet" type="text/css" />

</head>

<body style="background:#CCF">
<p>&nbsp;</p>
<p>&nbsp;</p>
<table width="400" border="0" align="center" cellpadding="0">
  <tr>
    <td><div style="border:#039 1px solid; padding:10px; background:#FFF">
      <?php if ($totalRows_notice > 0) { // Show if recordset not empty ?>
  <?php do { 
mysql_select_db($database_sepolwan_connect, $sepolwan_connect);
$query_komen_member = "SELECT * FROM memberdb WHERE id = '".$row_notice['id_member']."'";
$komen_member = mysql_query($query_komen_member, $sepolwan_connect) or die(mysql_error());
$row_komen_member = mysql_fetch_assoc($komen_member);
$totalRows_komen_member = mysql_num_rows($komen_member);
?>
  <a href="<?php echo $base ?><?php echo $row_sesi['nama_user']; ?>/artikel/<?php echo $row_notice['id_post']; ?>-notice.html">&quot;<?php echo $row_komen_member['full_name']; ?>&quot; mengomentari postingn anda &quot;<?php echo $row_notice['komentar']; ?>&quot; pada <?php echo tgl_indo($row_notice['waktu']), substr($row_notice['waktu'], 10, 6), " WIB"; ?></a>
        <div style="background:#036; width:100%; height:1px; margin:10px 0;"></div>
        <?php mysql_free_result($komen_member); } while ($row_notice = mysql_fetch_assoc($notice)); ?>
        <?php } // Show if recordset not empty 
		else { echo "Tidak Ada Notice"; }  ?>
    </div></td>
  </tr>
</table>

</body>
</html>
<?php
mysql_free_result($sesi);

mysql_free_result($notice);
?>
